<{if $block.icmspoll_singlepoll && !$block.icmspoll_singlepoll.hasVoted && $block.icmspoll_singlepoll.hasStarted }>
	<div class="icmspoll_singlepoll">
		<div class="singlepoll_question">
			<h2><span class="icmspoll_h2_block"><{$block.icmspoll_singlepoll.question}>
			<{if $block.icmspoll_singlepoll.userCanEditAndDelete}>
				(<{$block.icmspoll_singlepoll.editItemLink}>
				<{$block.icmspoll_singlepoll.deleteItemLink}>)
			<{/if}></span></h2>
		</div>
		<div class="singlepoll_description">
			<{$block.icmspoll_singlepoll.dsc}>
		</div>
		<div class="icmspoll_morelink">
		    <{if $icms_isuser}>
			<span class="more_polls_by"><{$smarty.const._MB_ICMSPOLL_PUBLISHER}>&nbsp;:&nbsp;<a href="<{$icmspoll_url}>index.php?op=getPollsByCreator&uid=<{$block.icmspoll_singlepoll.user_id}>"><{$icms_uname}></a>&nbsp;&nbsp;</span>
		    <{/if}>
		</div>
		<div class="singlepoll_form">
			<form id="pollform_block_<{$block.icmspoll_singlepoll.id}>" name="pollform_block_<{$block.icmspoll_singlepoll.id}>" class="icmspoll_pollform" action="<{$block.icmspoll_url}>submitpoll.php" method="post">
				<div class="option_set">
					<{foreach item=option from=$block.options name=options}>
						<div class="icmspoll_option_<{$option.color}> icmspoll_option_design">
							<label><input style="float:left;"  id="poll_option_block_<{$option.id}>" class="icmspoll_option_<{$option.inputtype}>" type="<{$block.icmspoll_singlepoll.inputtype}>" name="poll_option_block<{if $block.icmspoll_singlepoll.isMultiple}>[]<{/if}>"
									value="<{$option.id}>" <{if $smarty.foreach.options.first}>checked<{/if}> />
							<span style="float:left;padding-top:6px;padding-left: 3px;"><{$option.text}></span>
							</label>
						</div>
						<{$block.icmspoll_singlepoll.delimeter}>
					<{/foreach}>
				</div>
				<input type="hidden" name="user_id" value="<{$user_id}>" />
				<{if !$block.icmspoll_singlepoll.hasVoted  && $block.icmspoll_singlepoll.voteAccessGranted}>
					<div class="box">
						<input id="submit_poll_block_<{$block.icmspoll_singlepoll.id}>" name="submit_poll_block_<{$block.icmspoll_singlepoll.id}>" type="submit" class="btn icmspoll" value="<{$smarty.const._MB_ICMSPOLL_POLLS_SUBMIT}>" />
						<span class="helper"></span>
					</div>
				<{elseif !$block.icmspoll_singlepoll.hasVoted}>
					<div class="box">
						<input type="label" readonly size="50" class="btn icmspoll" value="<{$smarty.const._MB_ICMSPOLL_POLLS_ALREADYVOTED}>" />
					</div>
				<{else}>
				<{/if}>
			</form>
		</div>
	</div>
<{elseif $block.icmspoll_singlepoll.hasVoted || $block.icmspoll_singlepoll.hasExpired}>
	<div class="icmspoll_singlepoll">
		<div class="singlepoll_question">
			<h2><span class="icmspoll_h2_block"><{$block.icmspoll_singlepoll.question}>
			<{if $block.icmspoll_singlepoll.userCanEditAndDelete}>
				(<{$block.icmspoll_singlepoll.editItemLink}>
				<{$block.icmspoll_singlepoll.deleteItemLink}>)
			<{/if}></span></h2>
		</div>
		<div class="singlepoll_description">
			<p style="font-size:80%;"><{$smarty.const._CO_ICMSPOLL_POLL_HAS_ENDED}>&nbsp;:&nbsp;<{$block.icmspoll_singlepoll.end_time}></p>
			<{if $block.icmspoll_singlepoll.dsc}>
			    <p>&nbsp;</p>
			    <{$block.icmspoll_singlepoll.dsc}>
			    <p>&nbsp;</p>
			<{/if}>
			<{if $block.icmspoll_singlepoll.hasExpired}>
			    <{$smarty.const._CO_ICMSPOLL_POLL_HAS_EXPIRED_VISITOR}> &nbsp;<{$block.icmspoll_singlepoll.resultLink}>.
			<{/if}>
		</div>

		<div class="icmspoll_morelink">
		    <{if $icms_isuser}>
			<span class="more_polls_by"><a href="<{$icmspoll_url}>index.php?op=getPollsByCreator&uid=<{$block.icmspoll_singlepoll.user_id}>"><img src="<{$icmspoll_images_url}>other-user-poll.png" title="<{$smarty.const._CO_ICMSPOLL_POLLS_GET_MORE_BY_USER}> <{$icms_uname}>" /></a>&nbsp;&nbsp;</span>
		    <{/if}>
		</div>

		<div class="singlepoll_form">
		    <div class="poll_result">
		    	<div class="icmspoll_result_options">
	    			<{foreach item=option from=$options name=options}>
	    				<div class="result_option">
	    				   <div class="icmspoll_option_<{$option.color}> icmspoll_option_color" style="width:<{$option.result}>" >
	    				       &nbsp;
	    				   </div>
	    				   <div class="option_result_value">
	    				   		<{$option.result}>
	    				   </div>
	                    </div>
	                    <div class="icmspoll_clear_left">&nbsp;</div>
	    				<div class="poll_option_txt">
	    					<{$option.text}>
	    				</div>
	    				<{$block.icmspoll_singlepoll.delimeter}>
	    			<{/foreach}>
    			</div>
    		</div>
    		<div class="icmspoll_clear_left">&nbsp;</div>
			<{if $block.icmspoll_singlepoll.hasVoted && !$block.icmspoll_singlepoll.hasExpired}>
				<div class="box">
					<input id="submit_poll_<{$block.icmspoll_singlepoll.id}>" type="text" readonly size="50" class="btn voted icmspoll_voted" value="<{$smarty.const._MB_ICMSPOLL_POLLS_ALREADYVOTED}>" />
				</div>
			<{/if}>
		</div>
	</div>
<{/if}>
<div id="icmspoll_balert" style="display: none;">&nbsp;</div>
<script type="text/javascript">
	$(document).ready(function(){
		$("#submit_poll_block_<{$block.icmspoll_singlepoll.id}>").click(function(e) {
			e.preventDefault();
			$("#pollform_block_<{$block.icmspoll_singlepoll.id}>").submit();
			return false;
		});

		$("#pollform_block_<{$block.icmspoll_singlepoll.id}>").submit(function(e) {
			e.preventDefault();
			$.ajax({
				url: "<{$block.icmspoll_url}>submitpoll.php",
				type: "POST",
				dataType: "json",
				data: {
					poll_id: '<{$block.icmspoll_singlepoll.id}>',
					op: 'vote',
					poll_option: $("form#pollform_block_<{$block.icmspoll_singlepoll.id}> input[type=<{$block.icmspoll_singlepoll.inputtype}>]:checked").map(function(){return this.value;}).get().join(",")
				},
				success: function(response) {
					if(response.status === "success") {
						document.forms.pollform_block_<{$block.icmspoll_singlepoll.id}>.reset();
						$("#icmspoll_balert").html(response.message);
						$("#icmspoll_balert").dialog("open");
					} else if(response.status === "error") {
						document.forms.pollform_block_<{$block.icmspoll_singlepoll.id}>.reset();
						$("#icmspoll_balert").html(response.message);
						$("#icmspoll_balert").dialog("open");
					}
				}

			})
		});

		$("#icmspoll_balert").dialog({
			autoOpen: false,
			modal: true,
			hide: "clip",
			show: "clip",
			resizable: false,
			width: 800,
			height: "auto",
			buttons: {
				Ok: function() {
					$(this).html("");
					$(this).dialog( "close" );
					window.location.reload();
				}
			}
		});
	});
</script>